<?php
namespace App\Admin\Models;
use Common\BaseModel;
class Appconfig extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('f_app_config');
    }

    public function page_list($params=[]){
        if(isset($params['keywords']) && !empty($params['keywords'])){
            $condition = "title like '%{$params['keywords']}%'";
        }else{
            $condition = '';
        }
        $cate_list = $this::find(
            array(
                $condition,
                "order" => 'id desc',
            ));
        return $cate_list;
    }

    public function save_params($params){
        return $this::save($params);
    }

    public function find_by_key($key){
        $result = $this->findFirstByType($key);
        if($result){
            return $result->value;
        }else{
            return 0;
        }
    }

    public function get_list($is_show=1){
        $conditions = "is_show={$is_show}";
        $list = $this->find(array(
            $conditions,
        ))->toarray();
        return $list;
    }


    public function find_by_id($id){
        $result = $this->findFirstByid($id);
        if($result){
            return $result->value;
        }else{
            return 0;
        }
    }
    public function find_by_id_obj($id){
        $result = $this->findFirstByid($id);
        return $result;
    }


}
